<include file="Public:header"/>
<div class="cat">
<a href="__URL__/add"><img src="__APP__/statics/add_cat.gif" /></a>
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="40">排序</td>
		<td class="title" width="300">分类名称</td>
		<td class="title" width="100">类型</td>
		<td class="title" width="40">图标</td>
		<td class="title" width="80">添加子类</td>
		<td class="title" width="40">修改</td>
		<td class="title" width="40">删除</td>
		<td class="title" width="80">查看商品</td>
		<td class="title" width="40">浏览</td>
		<td class="title" width="40">显示</td>
		<td class="title" width="40">推荐</td>
		<td class="title">　</td>
	</tr>
<volist name="cat" id="cat">

	<tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="40"><input type="text" name="n_id[]" style="display:none" value="{$cat.cat_id}"><input name="sorting[]" size="10" type="text" value="{$cat.sorting}"></td>
<if condition="$cat.pid eq 0">
		<td width="300" style="font-weight:bold">[{$cat.fullname}]</td>
<else/>
        <td width="300">{$cat.fullname}</td>
</if>
		<td width="100">[{$cat.model_n}]</td>
		<td><if condition="$cat.icon neq ''"><img src="__APP__/statics/icons/cate/{$cat.icon}" width='25px' height="25px"></if></td>
		<td width="80" align="center"><a href="__URL__/add/?pid={$cat.cat_id}&model={$cat.model}"><img src="__APP__/statics/add44.gif"></a></td>
		<td width="40" align="center"><a href="__URL__/edit/?cat={$cat.cat_id}"><img src="__APP__/statics/icons/member3.gif"></a></td>
		<td width="40" align="center"><a href="javascript:;" onclick="delCat({$cat.cat_id})"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>
		<td width="80" align="center"><a href="__GROUP__/Goods/goods_list/?cat={$cat.cat_id}"><img src="__APP__/statics/icons/cart.gif"></a></td>
		<td width="40" align="center"><a href="__APP__/List/?cid={$cat.cat_id}" target="_blank"><img src="__APP__/statics/reg-t1.gif"></a></td>
		<td><if condition="$cat.is_active eq 0">显示<else/><font color='red'>不显示</font></if></td>
		<td><if condition="$cat.is_hot eq 1"><font color='green'>推荐</font><else/>不推荐</if></td>
		<td></td>
	</tr>
</volist>
</table>
</div>

<div id="save"><input id="sort" type="button" value="保存排序"></div>

<script>
$(function(){
    $("#sort").click(function(){
              var cat=[];
			  $("[name='n_id[]']").each(function(){
                     cat.push($(this).val()); 
               }); 
			   var sort=[];
			  $("[name='sorting[]']").each(function(){
                     sort.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/sorting",
					 dataType:"html",
					 data:{'cat':cat,'sort':sort},
					 success:function(data){
						location.reload();
					 }
			   })
	})
})

function delCat(t){
    var id=t;
	//jError("<strong>删除失败!请重试</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
	if(confirm('你确认删除此分类吗？如果有子分类或者该分类下有商品将无法删除！')) {
		$.ajax({
			 type:"POST",
			 url:"__URL__/del_cat",
			 dataType:"json",
			 data:{'id':id},
			 success:function(data){
				if(data=='0'){
					jError("<strong>删除失败!可能存在子分类或该分类下有未转移商品</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
				}else{
					jSuccess("<strong>删除成功！</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
					location.reload();
				}
			 }
		})
	}
}
</script>
